const axios = require('axios');

const BASE_URL = 'http://localhost:3001';

async function testSkillsData() {
  console.log('🧪 开始测试技能数据...\n');

  try {
    // 测试技能列表接口
    console.log('📋 测试技能列表接口');
    const response = await axios.get(`${BASE_URL}/api/skills`, {
      timeout: 5000
    });

    console.log(`✅ 测试结果: 成功`);
    console.log(`📝 状态码: ${response.status}`);
    console.log(`📝 响应数据: ${response.data.success ? '成功' : '失败'}`);
    
    if (response.data.success && response.data.data) {
      console.log(`📝 技能数量: ${response.data.data.length}`);
      console.log('📝 技能数据详情:');
      
      response.data.data.forEach((skill, index) => {
        console.log(`  技能${index + 1}:`);
        console.log(`    ID: ${skill.id} (类型: ${typeof skill.id})`);
        console.log(`    名称: ${skill.name || 'N/A'}`);
        console.log(`    类别: ${skill.category || 'N/A'}`);
        console.log(`    描述: ${skill.description || 'N/A'}`);
        console.log(`    完整数据: ${JSON.stringify(skill)}`);
        console.log('');
      });
    } else {
      console.log(`📝 错误信息: ${response.data.message || 'N/A'}`);
    }
  } catch (error) {
    console.log(`❌ 测试结果: 失败`);
    if (error.response) {
      console.log(`📝 状态码: ${error.response.status}`);
      console.log(`📝 错误信息: ${error.response.data?.message || error.message}`);
    } else {
      console.log(`📝 错误信息: ${error.message}`);
    }
  }

  console.log('🎉 技能数据测试完成！');
}

testSkillsData().catch(console.error); 